/**
 *    Copyright (C) 2008, 2009  Victor Smirnov <aist11@gmail.com>
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *    See LICENSE.exceptions in the root folder of this project for possible
 *    exceptions
 *
 */

#ifndef _CUBEFS_API_REFLECTION_LIST_HPP
#define	_CUBEFS_API_REFLECTION_LIST_HPP

#include <cubefs/api/reflection/value.hpp>
#include <string>

namespace cubefs    {
namespace api       {

struct CUBEFS_API List: public Value {
    virtual Int size() const                    				= 0;
    virtual void Remove(Int index)              				= 0;
    virtual void RemoveAll(Int from, Int to)    				= 0;
    virtual void Clear()                        				= 0;
    virtual Int GetElementSize() const          				= 0;

    virtual Typed* GetElement(Int index) const					= 0;
    virtual void GetElement(Int index, Value*) const			= 0;
    virtual void SetElement(Int index, const Typed* value)		= 0;

    virtual void Insert(Int index, const Typed* value)			= 0;
    virtual void Add(const Typed* value)						= 0;

    virtual Value* CreateValueHolder() const					= 0;
    virtual bool IsElementPrimitive() const						= 0;

    static Type* MyType();
};

CUBEFS_DECLARE_TYPENAME(List, "cubefs::api::List");

template <typename T, Int Size>
struct CUBEFS_API TypedList: public List {
	typedef T Element;

	virtual const T& Get(Int index) const						= 0;
	virtual void Set(Int index, const T& ) 						= 0;
	virtual void Insert(Int index, const T &value)				= 0;
	virtual void Add(const T& value)							= 0;

    static Type* MyType() {
    	return GetTypedListType(Size, TypeHash<T>::hash);
    }
};



typedef TypedList<StringValue*>									ListOfStrings;

CUBEFS_API Type* GetTypedListType(Int size, Int type_hash_code);

CUBEFS_DECLARE_PARAMETRIZED_TYPENAME1(TypedList, "cubefs::api::TypedList");

}
}



#endif
